from django.db import models
from django.utils import timezone
from users.models import User
# Create your models here.

class Product(models.Model):
    model = models.CharField(max_length=50,verbose_name='品牌')
    name = models.CharField(max_length=20,verbose_name='车名')
    img = models.ImageField(upload_to='static/timecar/',verbose_name='海报图')
    price = models.CharField(max_length=20, verbose_name='价格')
    rank = models.CharField(max_length=20,verbose_name='级别')
    endurance = models.CharField(max_length=20,verbose_name='续航')
    charge = models.CharField(max_length=20,verbose_name='快充')
    count = models.IntegerField(verbose_name='数量')

    def __str__(self):
        return self.name
    class Meta:
        verbose_name_plural='上市新车'

class ProductImage(models.Model):
    images = models.ImageField(upload_to='static/timecar/')
    product = models.ForeignKey(Product, on_delete=models.CASCADE)

    def __str__(self):
        return self.product.name
    class Meta:
        verbose_name_plural='新车海报'


#参与的活动
class Active(models.Model):
    model = models.CharField(max_length=50,verbose_name='品牌')
    name = models.CharField(max_length=20,verbose_name='车名')
    img = models.ImageField(upload_to='static/timecar/',verbose_name='海报图')
    price = models.CharField(max_length=20, verbose_name='价格')
    rank = models.CharField(max_length=20,verbose_name='级别')
    endurance = models.CharField(max_length=20,verbose_name='续航')
    charge = models.CharField(max_length=20,verbose_name='快充')
    users = models.ForeignKey(User,on_delete=models.CASCADE)
    product = models.ForeignKey(Product, on_delete=models.CASCADE)
